#!/bin/bash
#获取本地路径
ROOTDIR=$(cd $(dirname $0) && pwd )
UPLOAD="/data/upload_speeching"
DESUPLOAD="/data/var/webapi/audio/upload"
WAV="/data/box-recording"
DESWAV="/data/var/webapi/audio/wav"
MP3="/data/speech3"
DESMP3="/data/var/webapi/audio/mp3"
TLOG="/data/trans_log"
DESTLOG="/data/var/webapi/log/trans"
RLOG="/data/roles_log"
RESRLOG="/data/var/webapi/log/roles"


#判断文件源文件夹是否存在
if [ ! -d $ROOTDIR"/data" ];then
echo -e "源文件夹不存在";
echo -e "结束";
exit 0
fi

#开始转移音频文件
if [ ! -d $DESUPLOAD ]; then
echo -e "创建$DESUPLOAD文件夹"
sudo mkdir -p $DESUPLOAD
fi
echo -e "迁移上传文件中。。。";
sudo cp -r $ROOTDIR$UPLOAD"/" $DESUPLOAD
sudo chown -R apache:apache $DESUPLOAD

if [ ! -d $DESWAV ]; then
echo -e "创建$DESWAV文件夹"
sudo mkdir -p $DESWAV
fi
echo -e "迁移wav文件中。。。";
sudo cp -r $ROOTDIR$WAV"/" $DESWAV
sudo chown -R apache:apache $DESWAV

if [ ! -d $DESMP3 ]; then
echo -e "创建$DESMP3文件夹"
sudo mkdir -p $DESMP3
fi
echo -e "迁移MP3文件中。。。";
sudo cp -r $ROOTDIR$MP3"/" $DESMP3
sudo chown -R apache:apache $DESMP3

#开始转移日志文件
if [ ! -d $DESTLOG ]; then
echo -e "创建$DESTLOG文件夹"
sudo mkdir -p $DESTLOG
fi
echo -e "迁移转写日志文件中。。。";
sudo cp -r $ROOTDIR$TLOG"/" $DESTLOG
sudo chown -R apache:apache $DESTLOG

if [ ! -d $RESRLOG ]; then
echo -e "创建$RESRLOG文件夹"
sudo mkdir -p $RESRLOG
fi
echo -e "迁移角色分离文件中。。。";
sudo cp -r $ROOTDIR$RLOG"/" $RESRLOG
sudo chown -R apache:apache $RESRLOG

echo -e "迁移完毕！结束";
exit 0